<template>
  <div>

    <el-dialog
      title="OA办公自动化系统"
      :visible.sync="dialogVisible"
      width="40%"
      :before-close="handleClose">
      <el-form label-width="80px">
        <el-form-item label="账号:">
          <el-input v-model="user.username" clearable ></el-input>
        </el-form-item>
        <el-form-item label="密码:">
          <el-input v-model="user.password" clearable show-password></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="selectUser()">登 录</el-button>
        <el-button type="info" style="background-color: #FF6666;">注 册</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        dialogVisible: true,
        user: {
          username: "",
          password: ""
        }
      };
    },
    methods: {
      handleClose(done) {

      },
      async selectUser(){
        let {data: resultData} = await this.$http.get('/user/login',{params: this.user})
        if(resultData.status != 200){
          return this.$message.error('用户名或密码错误!!!')
        }
        let token = resultData.data
        window.sessionStorage.setItem('token',token)
        this.$message.success('登录成功!')
        this.$router.push("/home")
      }
    }
  };
</script>

<style>
  body{
    background-image: url(../assets/images/4.png);
    background-size: 100%

  }

</style>
